<?php
// 上传图片
// 上传错误
if ($_FILES['file_image']['error'] > 0) {
    exit(json_encode(array('error' => 1, 'data' => array())));
}
// 限制文件类型和大小
$allows = array('image/jpeg', 'image/png');
if (!in_array($_FILES['file_image']['type'], $allows)) {
    exit(json_encode(array('error' => 1, 'data' => array())));
}
move_uploaded_file($_FILES['file_image']['tmp_name'], $_SESSION['DOCUMENT_ROOT'] . 'images/' . $_FILES['file_image']['name']);
exit(json_encode(array('error' => 0, 'data' => array('images/' . $_FILES['file_image']['name']))));
